package opreation;

import book.*;

import java.util.Scanner;
import java.util.SequencedCollection;

/**
 * Created with IntelliJ IDEA.
 * Description:此类查找书籍操作
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2024-01-03  09:06
 */
public class FindOpreation implements IOpreation{
    @Override
    public void work(BookList bookList) {
        System.out.println("请输入查找书籍的名称：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.next();
        int currentSize = bookList.getUsedSize();
        for(int i = 0; i < currentSize; i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)) {
                System.out.println("找到此书，信息如下");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到此书！");
    }
}
